//
//  PKRadioTableViewCell.m
//  PianKe
//
//  Created by lanou on 15/12/23.
//  Copyright © 2015年 KFC. All rights reserved.
//

#import "PKRadioTableViewCell.h"

@implementation PKRadioTableViewCell



-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
       
        [self addSubViews];
       
    }
  
    return self;
   
}

- (void)addSubViews
{
    
    self.coverImageV = [[UIImageView alloc] initWithFrame:CGRectMake(10, 20, 60, 60)];
    
    [self.contentView addSubview:self.coverImageV];
    
    
    self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.coverImageV.right + 10, self.coverImageV.top, 200, 20)];
    [self.contentView addSubview:self.titleLabel];
    
    self.countimageV = [[UIImageView alloc] initWithFrame:CGRectMake(self.titleLabel.right + 10, self.titleLabel.top, 20, 20)];
    self.countimageV.image = [UIImage imageNamed:@"shengyin"];
    [self.contentView addSubview:self.countimageV];
    
    self.countLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.countimageV.right, self.countimageV.top, kScreenWidth - self.countimageV.right - 10, self.countimageV.height)];
    self.countLabel.textColor = [UIColor grayColor];
    self.countLabel.font = [UIFont systemFontOfSize:10];
    [self.contentView addSubview:self.countLabel];
    
    self.unameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.titleLabel.left, self.titleLabel.bottom, self.titleLabel.width, self.titleLabel.height)];
    self.unameLabel.textColor = [UIColor midnightBlueColor];
    self.unameLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.unameLabel];
    
    self.descLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.unameLabel.left, self.unameLabel.bottom, kScreenWidth - self.coverImageV.bottom - 10, self.unameLabel.height)];
    self.descLabel.font = [UIFont systemFontOfSize:12];
    self.descLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:self.descLabel];
    
    self.myNewImageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30,30)];
    [self.coverImageV addSubview:self.myNewImageV];
}


// 重写setModel方法
-(void)setModel:(PKRadioModel *)model
{
    
    _model = model;
    
    // 赋值
    [self.coverImageV sd_setImageWithURL:[NSURL URLWithString:model.coverimg] placeholderImage:nil];
    self.titleLabel.text = model.title;
    self.countLabel.text = [NSString stringWithFormat:@"%@",model.count];
    self.unameLabel.text = [NSString stringWithFormat:@"by:%@",model.uname];
    self.descLabel.text = model.desc;
    
    
    // 判断是否为新专辑
    if (model.isnew) {
        
       
        self.myNewImageV.image = [UIImage imageNamed:@"new2"];
        
    } else {
        
        // if else 里面的操作要对应,把image设为nil
        self.myNewImageV.image = nil;
    }
    
    
    
}











- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
